package com.briup.springboot_mybatisplus.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 使用注解表示当前类是配置类
 */
@MapperScan(basePackages = "com.briup.springboot_mybatisplus.dao")
//指定当前项目中哪个包下的接口是Mapper接口，创建该接口的实现类对象
@Configuration
public class MyBatisPlusConfig {
    //1.添加mybatis拦截器：拦截执行的查询语句，在查询语句添加分页关键字 limit
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
